<template>
	<view class="app">
		<!-- logo -->
		<view class="logo">
			<image src="../../../static/img/register/logo.png" mode=""></image>
		</view>
		<!-- 登录 -->
		<view class="conteng">
			<view class="loginTip">登录</view>
			<view class="loginInput">
				<view class="InputText">
					<image src="../../../static/img/register/register_tele.png" mode=""></image>
					<input type="text" v-model="phone" value="" placeholder-class="grayColor" placeholder="请输入手机号" />
				</view>
				
				<view class="InputText">
					<image src="../../../static/img/register/passwordIcon.png" mode=""></image>
					<input type="password" v-model="password" value="" placeholder-class="grayColor" placeholder="请输入密码" />
				</view>
			</view>
			<view class="forgetPas" @click="navRouter('/pages/register/login/ForgetPass')">忘记密码</view>
			
			<button class="registerButton" type="default" @tap="goidentity">登录</button>
		</view>
			

		<view class="goregister">
			<text>没有账号?</text>
			<text @click="reLaunch('/pages/register/login/register')">立即注册</text>
		</view>
	</view>
</template>

<script scoped>
	import login from "@/serve/api/login.js";
	import toMaintain from "@/serve/api/toMaintain.js"
	import {
		mapMutations
	} from "vuex"
	export default {
		data() {
			return {
				phone: "",
				password: "",
			}
		},
		onLoad() {
			// uni.hideLoading()
			// const path = plus.io.convertAbsoluteFileSystem('/pages/tabbar/home/home');
			// console.log(path)
			// console.log(plus.push.getClientInfo().clientid )
			// plus.push.createMessage( '收到一条新消息' );

		},
		methods: {
			...mapMutations(['setUserinfo']),
			async goidentity() {
				if (this.isEmpty(this.phone) || !this.checkPhone(this.phone)) {
					this.tip("请输入正确手机号")
					return
				} else if (this.isEmpty(this.password)) {
					this.tip("请输入密码")
					return
				};
				const res = await login.getLoginInfo({
					loginName: this.phone,
					password: this.password,
					
					// #ifdef APP-PLUS  
					cid:plus.push.getClientInfo().clientid,
					// #endif  
					loginType: 1,
					rememberMe: 1,
				});
				if (res) {
					uni.setStorageSync('token', res.data.data.token);
					const user = await toMaintain.selectSysUserById({
						flag: 1
					});
					console.log(user)
					if (user) {
						this.setUserinfo(user.data.data);
						if (user.data.data.reviewStatus == 2 || user.data.data.reviewStatus == 1) {
							uni.switchTab({
								url: "/pages/tabbar/home/home"
							})
						} else {
							uni.reLaunch({
								url: '/pages/register/identity/identity'
							});
						}
					}
				}
			},
		}
	}
</script>

<style scoped>
	@import url("@/static/css/login.css");
</style>
